<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
let username = ref('')
let password = ref('');
let router = useRouter();
function login(){
    if(username.value === 'root' && password.value === '123456'){
       //1.记录session值
       window.sessionStorage.setItem('username', username.value);
         //2.跳转到home
        router.push('/home');
    }else{
        alert('用户名或密码错误');
    }
}

</script>


<template>
    账号:<input type="text" v-model="username" /> <br>
    密码:<input type="password" v-model="password" />
    <button @click="login()">登录</button>
   
</template>